/********************************************************/
/*	Copyright (C) 2016 Gong Li Bin		 	*/
/*	Project:	GoLib-1.0.0			*/
/*	Author:		gong_libin			*/
/*	Date:		2016_01_01			*/
/*	File:		GoVec.go			*/
/********************************************************/

package GoCap

type GoVec	struct {
	cnt	uint64
	ptr	interface{}
}

func (v *GoVec) GoSetSort() {
}

func (v *GoVec) GoSetFind() {
}

func (v *GoVec) GoSetUniq() {
}

func (v *GoVec) GoSetOrder() {
}

func (v *GoVec) GoVecCnt() uint64 {
	return v.cnt
}

func (v *GoVec) GoVecPtr() interface{} {
	return v.ptr
}

func (v *GoVec) GoVecNew(ttl uint64) {
	v.ptr = make([]interface{}, ttl)
}

func (v *GoVec) GoVecNil(idx uint64) {
	v.ptr.([]interface{})[idx] = nil
}

func (v *GoVec) GoVecSet(l, r uint64) {
	for i := l; i < r; i ++ {
		v.GoVecNil(i)
	}
}

func (v *GoVec) GoVecPop() interface{} {
	var r interface{}
	for i := uint64(0); i < v.cnt; i ++ {
		if nil != v.ptr.([]interface{})[i] {
			r = v.ptr.([]interface{})[i]
			v.ptr.([]interface{})[i] = nil
			break
		}
	}
	return r
}

func (v *GoVec) GoVecAdd(ptr interface{}) {
	v.ptr.([]interface{})[v.cnt] = ptr
	v.cnt += 1
}

func (v *GoVec) GoVecGet(idx uint64) interface{} {
	r := v.ptr.([]interface{})[idx]
	v.ptr.([]interface{})[idx] = nil
	return r
}

func (v *GoVec) GoVecPut(idx uint64, ptr interface{}) {
	v.ptr.([]interface{})[idx] = ptr
}
